<template>
	<view class="body_wallet">
		<!-- <image :src="Url+'add_images/wallet.png'"></image> -->
		<image :src="Url+'add_images/wallet.png'"></image>
		<view class="money">{{accountData.balance}}</view>
		<view class="money_title">账户余额（元）</view>
		<view class="add_money" @tap="tovoucherCenter()" v-if="accountData.recharge">充值</view>
		<view class="add_money_end" v-else>正在开发中...</view>
		<view class="choose_item">
			<view class="item" @tap="toaccount(0)">充值记录</view>
			<view class="item" @tap="toaccount(1)">账单详情</view>
		</view>
		<shop-loading v-if="shopLoad"></shop-loading>
		<sc-home></sc-home>

	</view>
</template>

<script>
	import {
		getAccount
	} from '@/common/mine.js';
	export default {
		data() {
			return {
				Url: this.Imgurl,
				accountData: {},
				shopLoad: false
			}
		},
		onLoad() {
			this.shopLoad = true;
			this.getAccountData()
		},
		onShow() {
			if(uni.getStorageSync('mineRefresh')){
				this.getAccountData()
			}
		},
		methods: {
			getAccountData() {
				getAccount().then(res => {
					console.log(res)
					if (res.code == 1) {
						this.accountData = res.msg
						this.shopLoad = false;
					} else {
						this.shopLoad = false;
					}
				}).catch()
			},
			toaccount(key) {
				uni.navigateTo({
					url: '/pageD/account/accountBalance?index=' + key
				});
			},
			tovoucherCenter() {
				uni.navigateTo({
					url: '/pageD/account/voucherCenter'
				});
			}

		}

	}
</script>

<style lang="less" scoped>
	.body_wallet {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	image {
		margin-top: 25%;
		width: 240upx;
		height: 240upx;
	}

	.money {
		font-size: 56upx;
		font-weight: 700;
		margin-top: 10%;
		color: #333;
	}

	.money_title {
		margin-top: 2%;
		padding-left: 15upx;
		font-size: 28upx;
		color: #8b8b8b;
	}

	.add_money {
		width: 550upx;
		height: 90upx;
		margin-top: 20%;
		line-height: 90upx;
		overflow: hidden;
		border-radius: 50upx;
		background: #FF2842;
		color: #fff;
		text-align: center;
	}
	.add_money_end{
		width: 550upx;
		height: 90upx;
		margin-top: 20%;
		line-height: 90upx;
		overflow: hidden;
		border-radius: 50upx;
		background: -webkit-linear-gradient(left, #777777 0%, #B8B8B8 100%);
		color: #fff;
		text-align: center;
	}

	.choose_item {
		width: 550upx;
		margin-top: 14%;
		display: flex;
		font-size: 28upx;

		.item {
			flex: 1;
			text-align: center;
		}
	}
</style>
